from django.db import models

# Create your models here.
from django.db import models

class Manager(models.Model):
    user_manager = models.CharField(primary_key=True, max_length=255)
    password = models.CharField(max_length=255)
    class Meta:
        managed = False
        db_table = 'manager'


class Article_type(models.Model):
    cid = models.IntegerField(primary_key=True)
    pname = models.CharField(max_length=20)

    class Meta:
        managed = False
        db_table = 'article_type'
    @classmethod
    def first_category(cls):
        return cls.objects.first()
class Article(models.Model):
    aid = models.AutoField(primary_key=True)
    title = models.CharField(max_length=255)
    author = models.CharField(max_length=255)
    resource = models.CharField(max_length=255)
    time = models.DateTimeField()
    download = models.IntegerField()
    cid = models.ForeignKey('Article_type', models.DO_NOTHING, db_column='cid', related_name='articles', null=True)
    contend=models.CharField(max_length=10000)
    link=models.CharField(max_length=255)
    class Meta:
        managed = False
        db_table = 'article'


class Login(models.Model):
    id = models.AutoField(db_column='R_id', primary_key=True)  # Field name made lowercase.
    username = models.CharField(db_column='R_username', max_length=255)  # Field name made lowercase.
    password = models.CharField(db_column='R_password', max_length=255)  # Field name made lowercase.
    regtime = models.DateTimeField(db_column='R_regtime', blank=True, null=True)  # Field name made lowercase.
    sex = models.CharField(db_column='R_sex', max_length=255)  # Field name made lowercase.

    class Meta:
        managed = False
        db_table = 'login'

